%codifica(S,Etqh,Etq,Codh,Cod,Token,TokenValue).

codifica(_S,Etqh,Etq,Codh,Cod,nument,TokenValue):-
        append(Codh,[[Etqh,apila,265,TokenValue]],Cod),
        Etq is Etqh + 1.

codifica(_S,Etqh,Etq,Codh,Cod,numreal,TokenValue):-
        append(Codh,[[Etqh,apila,266,TokenValue]],Cod),
        Etq is Etqh + 1.

codifica([_Lex,ent,_Tam,Off,_TD],Etqh,Etq,Codh,Cod,ent,_TokenValue):-   
        append(Codh,[[Etqh,apila,265,Off]],Cod),
        Etq is Etqh + 1.

codifica([_Lex,real,_Tam,Off,_TD],Etqh,Etq,Codh,Cod,real,_TokenValue):- 
        append(Codh,[[Etqh,apila,265,Off]],Cod),
        Etq is Etqh + 1.

codifica(_TSh,Etqh,Etq,Codh,Cod,puntero,TokenValue):-
        append(Codh,[[Etqh,apilaind,TokenValue]],Cod),
        Etq is Etqh + 1.

codifica(_TSh,Etqh,Etq,Codh,Cod,registro,_TokenValue):-
        append(Codh,[[Etqh,suma,265]],Cod),
        Etq is Etqh + 1.

codifica(TSh,Etqh,Etq,Codh,Cod,array,Indice):-
        append(Codh,[[Etqh,apila,265,Indice]],Cod1),
        elemento(TSh,3,TamElemento),
        Etq1 is Etqh + 1,
        append(Cod1,[[Etq1,apila,265,TamElemento]],Cod2),
        Etq2 is Etq1 + 1,
        append(Cod2,[[Etq2,multiplica,265]],Cod3),
        Etq3 is Etq2 + 1,
        append(Cod3,[[Etq3,suma,265]],Cod),
        Etq is Etq3 + 1.

codifica([_,_Token,_,Off,_],Etqh,Etq,Codh,Cod,id,_TokenValue):-
        append(Codh,[[Etqh,apila,265,Off]],Cod),
        Etq is Etqh + 1.

codifica([_,Token,Tam,_,_],Etqh,Etq,Codh,Cod,valor,_TokenValue):-
        append(Codh,[[Etqh,apilaInd,Token,Tam]],Cod),
        Etq is Etqh + 1.

codifica(_,Etqh,Etq,Codh,Cod,'+',_TokenValue):-
        append(Codh,[[Etqh,suma]],Cod),
        Etq is Etqh + 1.

codifica(_,Etqh,Etq,Codh,Cod,'-',_TokenValue):-
        append(Codh,[[Etqh,resta]],Cod),
        Etq is Etqh + 1.

codifica(_,Etqh,Etq,Codh,Cod,'*',_TokenValue):-
        append(Codh,[[Etqh,multiplicacion]],Cod),
        Etq is Etqh + 1.

codifica(_,Etqh,Etq,Codh,Cod,'/',_TokenValue):-
        append(Codh,[[Etqh,division]],Cod),
        Etq is Etqh + 1.

codifica(_,Etqh,Etq,Codh,Cod,neg,_TokenValue):-
        append(Codh,[[Etqh,neg]],Cod),
        Etq is Etqh + 1.

codifica(_,Etqh,Etq,Codh,Cod,abs,_TokenValue):-
        append(Codh,[[Etqh,abs]],Cod),
        Etq is Etqh + 1.

codifica(_,Etqh,Etq,Codh,Cod,sqr,_TokenValue):-
        append(Codh,[[Etqh,sqr]],Cod),
        Etq is Etqh + 1.

codifica(_,Etqh,Etq,Codh,Cod,alto,_TokenValue):-
        append(Codh,[[Etqh,alto]],Cod),
        Etq is Etqh + 1.

codifica(_,Etqh,Etq,Codh,Cod,asig,_TokenValue):-
        append(Codh,[[Etqh,desapilaind]],Cod),
        Etq is Etqh + 1.

codifica(_,Etqh,Etq,Codh,Cod,mientras,TokenValue):-
        append(Codh,[[Etqh,ir-f,TokenValue]],Cod),
        Etq is Etqh + 1.

codifica(_,Etqh,Etq,Codh,Cod,finMientras,TokenValue):-
        append(Codh,[[Etqh,ir-a,TokenValue]],Cod),
        Etq is Etqh + 1.

codifica(_,Etqh,Etq,Codh,Cod,si,TokenValue):-
        append(Codh,[[Etqh,ir-f,TokenValue]],Cod),
        Etq is Etqh + 1.

codifica(_,Etqh,Etq,Codh,Cod,sino,TokenValue):-
        append(Codh,[[Etqh,ir-a,TokenValue]],Cod),
        Etq is Etqh + 1.

codifica(_,Etqh,Etq,Codh,Cod,'<',_TokenValue):-
        append(Codh,[[Etqh,menor]],Cod),
        Etq is Etqh + 1.

codifica(_,Etqh,Etq,Codh,Cod,'<=',_TokenValue):-
        append(Codh,[[Etqh,menorIgual]],Cod),
        Etq is Etqh + 1.

codifica(_,Etqh,Etq,Codh,Cod,'>',_TokenValue):-
        append(Codh,[[Etqh,mayor]],Cod),
        Etq is Etqh + 1.

codifica(_,Etqh,Etq,Codh,Cod,'>=',_TokenValue):-
        append(Codh,[[Etqh,mayorIgual]],Cod),
        Etq is Etqh + 1.

codifica(_,Etqh,Etq,Codh,Cod,'<>',_TokenValue):-
        append(Codh,[[Etqh,distinto]],Cod),
        Etq is Etqh + 1.

codifica(_,Etqh,Etq,Codh,Cod,'=',_TokenValue):-
        append(Codh,[[Etqh,igual]],Cod),
        Etq is Etqh + 1.

codifica(_,Etqh,Etq,Codh,Cod,fvar,TokenValue):-
        append(Codh,[[Etqh,incrementa,TokenValue]],Cod),
        Etq is Etqh + 1.

imprime([]).

imprime([C|R]):-
        tell('G:/Documentos/Universidad/4_/PLG/Grupo/practicas de otros/Rekai dcg/salida.txt'),
        write(C),
        nl,
        imprime(R),
        told.
